<?
$pacth="C:/xampp/htdocs/05_NIV/";
require ($pacth.'Model/SYSModel.php');
$sys=new SystemModule();
if(isset($_REQUEST["action"])){
    switch ($_REQUEST["action"]){
        case "login-network":
            $_SESSION[ "JO_account_name"		]="Network";
            JO_location("../Network");
            break;
        case "login-admin":
            $_SESSION[ "JO_account_name"		]="Admin";
            JO_location("../Admin");
            break;
        case"login":
            $u		=isset($_REQUEST["u"])?$_REQUEST["u"]:"";
            $p		=isset($_REQUEST["p"])?$_REQUEST["p"]:"";
            $rlogin=$sys->NIVLogin($u, $p);
            if($rlogin){
                    JO_location();
            }else{
                    echo "<strong class='system_title'>Access Denied</strong> - Username or password is wrong, please try again";
            }
            break;
        case"login-form":
            $u		=isset($_REQUEST["txtu"])?$_REQUEST["txtu"]:"";
            $p		=isset($_REQUEST["txtp"])?$_REQUEST["txtp"]:"";
            $rlogin=$sys->NIVLogin($u, $p);
            if($rlogin){
                    JO_location();
            }else{
                    echo "
                        <script>
                            document.getElementsById('errmsg').innerHTML(<strong class='system_title'>Access Denied</strong> - Username or password is wrong, please try again);
                            document.getElementsByClass('system_messages').show();
                        </script>
                        ";
            }
            break;
        case"logout":
            $sys->NIVLogout();
        	JO_location();
            break;
        case "saveSetting":
        	$bnone		=isset($_REQUEST["bnone"])?$_REQUEST["bnone"]:"none";
        	$bred		=isset($_REQUEST["bred"])?$_REQUEST["bred"]:"red";
        	$bblue		=isset($_REQUEST["bblue"])?$_REQUEST["bblue"]:"blue";
        	$bgreen		=isset($_REQUEST["bgreen"])?$_REQUEST["bgreen"]:"green";
        	$bpurple	=isset($_REQUEST["bpurple"])?$_REQUEST["bpurple"]:"purble";
        	$rowdisplay	=isset($_REQUEST["rowdisplay"])?$_REQUEST["rowdisplay"]:"10";
        	
        	if($sys->saveSetting($bnone, $bred, $bblue, $bgreen, $bpurple,$rowdisplay)){
        		$labels=array	(
					"bnone"=>$bnone,
					"bred"=>$bred,
					"bblue"=>$bblue,
					"bgreen"=>$bgreen,
					"bpurple"=>$bpurple,
					);
            	$_SESSION[ "label"		] = $labels;
            	$_SESSION[ "numrow"		]=$rowdisplay;
            	echo "Sussess.";
        	}else{
        		echo "Error.Cant save the setting";
        	}
        	break;
    }
}
?>